package util;

import java.io.File;
import java.io.FilenameFilter;

public class RemoveDirs {
    public static void main(String[] args) {
        String basePath = "C:\\projects\\seotools";
        File[] folders = new File(basePath).listFiles();
        clean(folders);
    }

    static public boolean deleteDirectory(File path) {
        if (path.exists()) {
            File[] files = path.listFiles();
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    deleteDirectory(files[i]);
                } else {
                    files[i].delete();
                }
            }
        }
        return (path.delete());
    }

    public static void clean(File[] folders) {
        for (File folder : folders) {
            if (folder.isFile()) {
                continue;
            } else if (folder.getName().equals(".svn")) {
                deleteDirectory(folder);
            } else if (folder.listFiles().length != 0) {
                clean(folder.listFiles());
            }
        }
    }
}
